//
//  NWNetworkGeneralParamters.m
//  NWBaseProject
//
//  Created by YueWen on 2018/9/25.
//  Copyright © 2018年 YueWen. All rights reserved.
//

#import "NWNetworkGeneralParamters.h"
#import "QDObtainUserIDFVTool.h"
#import <UIKit/UIKit.h>
#import "QDMetroClient-Swift.h"
#import <UIDeviceIdentifier/UIDeviceHardware.h>

@interface NWNetworkGeneralParamters ()

/**
 统一追加的参数，每次网络请求都会被调用
 默认为deviceModel、systemname、systemversion、appversion、deviceid
 如果完全不符合，重写该参数即可
 */
//@property (nonatomic, copy)NSDictionary *generalParamters;


/**
 拓展参数
 generalParamters参数都可用，另外追加的参数可以赋值该语句。
 */
@property (nonatomic, copy)NSDictionary *extendParamters;

@end

@implementation NWNetworkGeneralParamters

- (instancetype)init
{
    if (self = [super init]){
        
        NSMutableDictionary *parametersInfo = [NSMutableDictionary dictionaryWithCapacity:5];
        
        UIDevice *device = UIDevice.currentDevice;
        
        // 追加手机信息
        [parametersInfo addEntriesFromDictionary:@{@"model":UIDeviceHardware.platformStringSimple}];//iPhone 6s
        [parametersInfo addEntriesFromDictionary:@{@"platform":device.systemName}];//iOS
        // 系统版本号
        [parametersInfo addEntriesFromDictionary:@{@"systemversion":device.systemVersion}];//4.0
        // 追加app版本号
        [parametersInfo addEntriesFromDictionary:@{@"version" : NSDictionary.ritl_version}];//1.0
        // 追加 机器唯一编码
        [parametersInfo addEntriesFromDictionary:@{@"deviceCoding" : QDObtainUserIDFVTool.getIDHardwareCode}];
        
        //追加测试token
        if (QDUserStatus.isLogin) {//如果登陆了，追加token
            [parametersInfo addEntriesFromDictionary:@{@"token": QDUserInfoModelObjc.token}];
        }


        self.extendParamters = @{};
    }
    
    return self;
}




+ (NSDictionary *)generalParamters{
    
    NSMutableDictionary *parametersInfo = [NSMutableDictionary dictionaryWithCapacity:5];
    
    UIDevice *device = UIDevice.currentDevice;
    
    // 追加手机信息
    [parametersInfo addEntriesFromDictionary:@{@"model":UIDeviceHardware.platformStringSimple}];//iPhone 6s
    [parametersInfo addEntriesFromDictionary:@{@"platform":device.systemName}];//iOS
    // 系统版本号
    [parametersInfo addEntriesFromDictionary:@{@"systemversion":device.systemVersion}];//4.0
    // 追加app版本号
    [parametersInfo addEntriesFromDictionary:@{@"version" : NSDictionary.ritl_version}];//1.0
    // 追加 机器唯一编码
    [parametersInfo addEntriesFromDictionary:@{@"deviceCoding" : QDObtainUserIDFVTool.getIDHardwareCode}];
    // 中英文
//    [parametersInfo addEntriesFromDictionary:@{@"language" : QDLanguage.localIdentifier}];

    if (QDUserStatus.isLogin) {//如果登陆了，追加token
        [parametersInfo addEntriesFromDictionary:@{@"token": QDUserInfoModelObjc.token}];
    }
    
//#warning 测试
    
//     /// 测试消息
//    [parametersInfo addEntriesFromDictionary:@{@"token": @"9636551B66F79B20640BD6AB413A6599"}];
//    [parametersInfo addEntriesFromDictionary:@{@"deviceCoding": @"dcf229ba609ee141"}];
//
    /// 测试乘车
//    [parametersInfo addEntriesFromDictionary:@{@"token": @"00A460B52CA965EC69EDC2E26AC336AB"}];
//    [parametersInfo addEntriesFromDictionary:@{@"model":@"AndroidSDKbuiltforx86_64"}];
//    [parametersInfo addEntriesFromDictionary:@{@"deviceCoding": @"6EF61147-8A3A-4D99-BA93-01028CAFDFBF"}];

    return parametersInfo;
}

@end
